package com.siqi.hr.common;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author xiaogq
 * 整个hr系统常量工具类
 */
public class Constants {
	//定义读取mongo配置文件Properties对象
	private static Properties mongoPropertis = new Properties();
	//定义读取redis配置文件Properties对象
	private static Properties redisPropertis = new Properties();
	//定义读取系统配置文件Properties对象
	private static Properties systemPropertis = new Properties();
	//定义读取钉钉配置文件Properties对象
	private static Properties dingPropertis = new Properties();
	//定义读取OSS配置文件Properties对象
	private static Properties ossPropertis = new Properties();

	static {
		if(mongoPropertis == null){
			mongoPropertis = new Properties();
		}
		try {
			InputStream is = Constants.class.getResourceAsStream("/config/mongo.properties");
			mongoPropertis.load(is);
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static {
		if(redisPropertis == null){
			redisPropertis = new Properties();
		}
		try {
			InputStream is = Constants.class.getResourceAsStream("/config/redis.properties");
			redisPropertis.load(is);
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static {
		if(systemPropertis == null){
			systemPropertis = new Properties();
		}
		try {
			InputStream is = Constants.class.getResourceAsStream("/config/system.properties");
			systemPropertis.load(is);
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static {
		if(dingPropertis == null){
			dingPropertis = new Properties();
		}
		try {
			InputStream is = Constants.class.getResourceAsStream("/config/ddconfig.properties");
			dingPropertis.load(is);
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static {
		if(ossPropertis == null){
			ossPropertis = new Properties();
		}
		try {
			InputStream is = Constants.class.getResourceAsStream("/config/ossconfig.properties");
			ossPropertis.load(is);
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	/**  读取系统配置 **/
	//思齐云平台链接地址
	public static final String P_URL_TOKEN=systemPropertis.getProperty("p.url.token");
	//思齐云平台
	public static final String P_URL=systemPropertis.getProperty("p.url");

	/**  读取MongoDB配置 **/
	//获取MongoDB用户名
	public static final String LONGINNAME = mongoPropertis.getProperty("mongo.loginName");
	//获取MongoDB密码
	public static final String PASSWORD = mongoPropertis.getProperty("mongo.passWord");
	//获取MongoDB服务ip地址
	public static final String HOSTNAME = mongoPropertis.getProperty("mongo.hostName");
	//获取MongoDB服务端口
	public static final int PORT = Integer.parseInt(mongoPropertis.getProperty("mongo.port") == null ? "27017" : mongoPropertis.getProperty("mongo.port"));
	//获取MongoDB数据库名
	public static final String DATADB = mongoPropertis.getProperty("mongo.dataDB");
	//获取MongoDB系统库名
	public static final String SYSDB = mongoPropertis.getProperty("mongo.sysDB");
	//获取MongoDB日志库名
	public static final String LOGDB = mongoPropertis.getProperty("mongo.logDB");
	//获取MongoDB图表库名
	public static final String CHARTDB = mongoPropertis.getProperty("mongo.chartDB");
	//MongoDB中每次查询返回的记录数
	public static final int BATCHSIZE = Integer.parseInt(redisPropertis.getProperty("mongo.batchSize") == null ? "10000" : redisPropertis.getProperty("mongo.batchSize"));

	/**  Redis信息配置Start **/
	public final static int REDIS_MAXACTIVE = Integer.parseInt(redisPropertis.getProperty("redis.pool.maxActive") == null ? "300" : redisPropertis.getProperty("redis.pool.maxActive"));
	public final static int REDIS_MAXIDLE = Integer.parseInt(redisPropertis.getProperty("redis.pool.maxIdle") == null ? "5" : redisPropertis.getProperty("redis.pool.maxIdle"));
	public final static int REDIS_MAXWAIT = Integer.parseInt(redisPropertis.getProperty("redis.pool.maxWait") == null ? "100000" : redisPropertis.getProperty("redis.pool.maxWait"));
	public final static boolean REDIS_TESTONBORROW = Boolean.parseBoolean(redisPropertis.getProperty("redis.pool.testOnBorrow") == null ? "true" : redisPropertis.getProperty("redis.pool.testOnBorrow"));
	public final static String REDIS_IP = redisPropertis.getProperty("redis.ip");
	public final static int REDIS_PORT = Integer.parseInt(redisPropertis.getProperty("redis.port") == null ? "6379" : redisPropertis.getProperty("redis.port"));
	public static final int REPORT_KEY_TIME = Integer.parseInt(redisPropertis.getProperty("redis.report.key") == null ? "600" : redisPropertis.getProperty("redis.report.key"));
	public final static int REDIS_DELAY = Integer.parseInt(redisPropertis.getProperty("redis.delay") == null ? "100000" : redisPropertis.getProperty("redis.delay"));
	//以下是配置redis数据库的索引xiaogq
	//redis默认使用的数据库，redis默认配置有16个数据库(0~15)这里我给配置了8个数据库【0～7】
	//默认数据库
	public final static int DEFAULTDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.defaultDB") == null ? "0" : redisPropertis.getProperty("redis.defaultDB"));
	//索引为1的数据库
	public final static int ONEDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.oneDB") == null ? "1" : redisPropertis.getProperty("redis.oneDB"));
	//索引为2的数据库
	public final static int TWODB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.twoDB") == null ? "2" : redisPropertis.getProperty("redis.twoDB"));
	//索引为3的数据库
	public final static int THREEDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.threeDB") == null ? "3" : redisPropertis.getProperty("redis.threeDB"));
	//索引为4的数据库
	public final static int FOURDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.fourDB") == null ? "4" : redisPropertis.getProperty("redis.fourDB"));
	//索引为5的数据库
	public final static int FIVEDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.fiveDB") == null ? "5" : redisPropertis.getProperty("redis.fiveDB"));
	//索引为6的数据库,人资系统在使用
	public final static int SIXDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.sixDB") == null ? "6" : redisPropertis.getProperty("redis.sixDB"));
	//索引为7的数据库
	public final static int SEVENDB_INDEX = Integer.parseInt(redisPropertis.getProperty("redis.sevenDB") == null ? "7" : redisPropertis.getProperty("redis.sevenDB"));

	/**
	 * 钉钉属性配置
	 */
	//访问地址
	public final static String OAPI_HOST = dingPropertis.getProperty("dd.oapi_host");
	//CorpId
	public final static String CORP_ID = dingPropertis.getProperty("dd.corp_id");
	//秘钥
	public final static String CORP_SECRET = dingPropertis.getProperty("dd.corp_secret");
	//免登陆秘钥
	public final static String SSO_SECRET = dingPropertis.getProperty("dd.sso_secret");
	//微应用 工资条id
	public final static String AGENT_ID_SALARY = dingPropertis.getProperty("dd.agent_id_salary");
	//微应用 思齐百问id
	public final static String AGENT_ID_ANSWER = dingPropertis.getProperty("dd.agent_id_answer");
	//微应用 人资id
	public final static String AGENT_ID_HR = dingPropertis.getProperty("dd.agent_id_hr");
	//微应用 伯乐推荐id
	public final static String AGENT_ID_BOLE = dingPropertis.getProperty("dd.agent_id_bole");

	/**
	 * OSS属性配置
	 */
	//endpoint是访问OSS的域名
	public final static String OSS_ENDPOINT = ossPropertis.getProperty("oss.endpoint");
	public final static String OSS_ACCESS_KEY_ID = ossPropertis.getProperty("oss.access_key_id");
	public final static String OSS_ACCESS_KEY_SECRET = ossPropertis.getProperty("oss.access_key_secret");
	//队列名
	public final static String OSS_BUCKET_NAME = ossPropertis.getProperty("oss.bucket_name");
	//OSS存储路径
	public final static String OSS_PATH_IMAGES = ossPropertis.getProperty("oss.path.images");
	public final static String OSS_PATH_FILES = ossPropertis.getProperty("oss.path.files");
	public final static String OSS_PATH_CONTRACT = ossPropertis.getProperty("oss.path.contract");
	public final static String OSS_URL = ossPropertis.getProperty("oss.url");


	//获取系统管理员角色id
	public final static String ROOTROLEID = systemPropertis.getProperty("role.rootRoleId") == null ? "00ILbBp19ZOy" : systemPropertis.getProperty("role.rootRoleId");
	//获取系统管理员部门id
	public final static String ROOTDEPTID = systemPropertis.getProperty("dept.rootDeptId") == null ? "1" : systemPropertis.getProperty("dept.rootDeptId");
	//获取系统管理员员工id
	public final static String ROOTEMPID = systemPropertis.getProperty("emp.rootEmpId") == null ? "AdminMananger" : systemPropertis.getProperty("emp.rootEmpId");
	//获取HR系统版本号
	public final static String HR_VERDION = systemPropertis.getProperty("hr.version") == null ? "1.0.0" : systemPropertis.getProperty("hr.version");
	//获取系统名称
	public final static String SYSTEM_NAME = systemPropertis.getProperty("system.name") == null ? "系统框架" : systemPropertis.getProperty("system.name");

	//获取服务器物理地址
	public final static String SYSTEM_WEBROOT = systemPropertis.getProperty("system.webroot") == null ? "D:/Tomcat6.0/webapps" : systemPropertis.getProperty("system.webroot");
	//获取上传文件的位置
	public final static String FILE_PATH = systemPropertis.getProperty("system.uploadFile") == null ? "/filePath" : systemPropertis.getProperty("system.uploadFile");
	//获取文件上传地址
	public final static String UPLOAD_FILE_LOCATION = SYSTEM_WEBROOT + FILE_PATH;
	//获取导出文件存取地址
	public final static String EXPORT_FILE_PATH = systemPropertis.getProperty("export.file.path","download\\export\\");


	public static void main(String [] args){
		System.out.println(HOSTNAME+"   "+PORT+"    "+REDIS_IP+"   "+REDIS_PORT+"   "+SYSTEM_NAME);
		String uncode = System.getProperty("file.encoding");
		System.out.println("uncode===="+uncode);
	}

}
